package com.cn.web.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.annotation.WebServlet;
import java.io.FileFilter;
import java.io.IOException;


@WebFilter("/*")
public class FilterDemo implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        System.out.println("1. FilterDemo...");
        //1.放行前，对request数据进行处理
        //放行后，才能访问相应的资源
        chain.doFilter(request, response);
        //2. 放行后，对Response数据进行处理
        System.out.println("3. FilterDemo");

    }

    @Override
    public void destroy() {

    }
}
